package com.zb.vo;

import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.zb.entity.AccounLoginInfo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

/**
 * @Author WEN
 * @Date 2024/3/23 0023
 **/
@Data
@Accessors(chain = true)
@ApiModel("发送短信对象")
public class SmsSendLogVo {
    @ApiModelProperty(value = "主健ID")
    private Long id;

    @ApiModelProperty(value = "商家ID")
    private Long custAccId;

    @ApiModelProperty(value = "短信类型：1-验证类短信，2-通知类，3-推广类短信")
    private Integer type;

    @ApiModelProperty(value = "短信模板编号")
    private String smsCode;

    @ApiModelProperty(value = "模板名称")
    private String name;

    @ApiModelProperty(value = "短信发送者名称")
    private String sendUser;

    @ApiModelProperty(value = "短信接收者手机号")
    private String receiveUserPhone;

    @ApiModelProperty(value = "短信接收者名称")
    private String receiveUsername;

    @ApiModelProperty(value = "发送的短信内容")
    private String receiveContent;

    @ApiModelProperty(value = "发送失败原因")
    private String failtReason;

    /**
     * @param loginInfo
     * @param type 短信类型：1-验证类短信，2-通知类，3-推广类短信
     * @param smsCode
     * @param templateName
     * @param receiveUserPhone
     * @param receiveUsername
     * @param receiveContent
     * @return
     */
    public static SmsSendLogVo sms(AccounLoginInfo loginInfo, Integer type, String smsCode, String templateName, String receiveUserPhone, String receiveUsername, String receiveContent, String failtReason) {
        return new SmsSendLogVo()
                .setId(IdWorker.getId())
                .setCustAccId(loginInfo.getCustAccId())
                .setType(type)
                .setSmsCode(smsCode)
                .setName(templateName)
                .setSendUser(loginInfo.getName())
                .setReceiveUserPhone(receiveUserPhone)
                .setReceiveUsername(null == receiveUsername? "" : receiveUsername)
                .setReceiveContent(null == receiveContent? "" : receiveContent)
                .setFailtReason(null == failtReason? "" : failtReason);
    }

    /**
     * @param loginInfo
     * @param type 短信类型：1-验证类短信，2-通知类，3-推广类短信
     * @param smsCode
     * @param templateName
     * @param receiveUserPhone
     * @param receiveUsername
     * @param receiveContent
     * @return
     */
    public static SmsSendLogVo sms(AccounLoginInfo loginInfo, Integer type, String smsCode, String templateName, String receiveUserPhone, String receiveUsername, String receiveContent) {
        return sms(loginInfo, type, smsCode, templateName, receiveUserPhone, receiveUsername, receiveContent, "");
    }

    /**
     * 短信关闭消息
     * @param loginInfo
     * @param type 短信类型：1-验证类短信，2-通知类，3-推广类短信
     * @param smsCode
     * @param templateName
     * @param receiveUserPhone
     * @param receiveUsername
     * @param receiveContent
     * @return
     */
    public static SmsSendLogVo smsOff(AccounLoginInfo loginInfo, Integer type, String smsCode, String templateName, String receiveUserPhone, String receiveUsername, String receiveContent) {
        return sms(loginInfo, type, smsCode, templateName, receiveUserPhone, receiveUsername, receiveContent, "商家已关闭短信发送通道，如要发送短信，请启用短信后重试！");
    }

    /**
     * 短信余额不足
     * @param loginInfo
     * @param type
     * @param smsCode
     * @param templateName
     * @param receiveUserPhone
     * @param receiveUsername
     * @param receiveContent
     * @return
     */
    public static SmsSendLogVo smsBalanceoweFee(AccounLoginInfo loginInfo, Integer type, String smsCode, String templateName, String receiveUserPhone, String receiveUsername, String receiveContent) {
        return sms(loginInfo, type, smsCode, templateName, receiveUserPhone, receiveUsername, receiveContent, "商家短信数量不足，发送失败，请充值后重新发送！");
    }





}
